<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>SWF::Movie - SWF Movie class</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:feedback@suse.de" />
</head>

<body style="background-color: white">


<!-- INDEX BEGIN -->
<div name="index">
<p><a name="__index__"></a></p>

<ul>

	<li><a href="#name">NAME</a></li>
	<li><a href="#synopsis">SYNOPSIS</a></li>
	<li><a href="#description">DESCRIPTION</a></li>
	<li><a href="#methods">METHODS</a></li>
	<li><a href="#example">EXAMPLE</a></li>
	<li><a href="#author">AUTHOR</a></li>
	<li><a href="#see_also">SEE ALSO</a></li>
</ul>

<hr name="index" />
</div>
<!-- INDEX END -->

<p>
</p>
<h1><a name="name">NAME</a></h1>
<p>SWF::Movie - SWF Movie class</p>
<p>
</p>
<hr />
<h1><a name="synopsis">SYNOPSIS</a></h1>
<pre>
        use SWF::Movie;</pre>
<pre>
        $m = new SWF::Movie();
        $m = SWF::Movie::newSWFMovieWithVersion(8);</pre>
<p>
</p>
<hr />
<h1><a name="description">DESCRIPTION</a></h1>
<p>SWF::Movie is the root object of your flashfile. It contains all your other objects you want in your movie.
Ming supports many Flash4, Flash5 F6,7,8,9.. features.</p>
<p>The SWF::Movie object contains information like the flashversion, the size, the frames per second, the background color. Except that, the SWF::Movie behaves like 
a SWF::MovieClip. It only cannot be added to another SWF::Movie or SWF::MovieClip.</p>
<p>Notice: The version of your flashmovie can be set by the object SWF. See SWF for more details.</p>
<p>
</p>
<hr />
<h1><a name="methods">METHODS</a></h1>
<dl>
<dt><strong><a name="movie" class="item">$m = new SWF::Movie()</a></strong>

<dd>
<p>Creates a Movie object.</p>
</dd>
</li>
<dt><strong><a name="newswfmoviewithversion" class="item">$m = newSWFMovieWithVersion(version)</a></strong>

<dd>
<p>Creates a Movie object with version value (e.g. 8) set.</p>
</dd>
</li>
<dt><strong><a name="add" class="item">$displayItem=$m-&gt;<code>add($SWFObject)</code></a></strong>

<dd>
<p>Add an instance of a SWF-object to your current frame. The returnvalue is a SWF::DisplayItem.</p>
</dd>
<dd>
<pre>
        Some possible SWF-objects are:</pre>
</dd>
<dd>
<pre>
        SWF::Action
        SWF::MovieClip
        SWF::Shape
        SWF::Sound
        SWF::Text
        SWF::TextField
        SWF::Bitmap
        SWF::PrebuiltClip</pre>
</dd>
<dd>
<pre>
        $m-&gt;add($shape); # possible, but not more accessible for us
        $shape_1 = m-&gt;add($shape); # good instance</pre>
</dd>
</li>
<dt><strong><a name="addexport" class="item">$m-&gt;addExport($block, $name)</a></strong>

<dd>
<p>Prepare linkage to Action script code.</p>
</dd>
<dd>
<pre>
        $m-&gt;addExport($mc, 'mc');
        # and later inside action script....:
        $ac = new SWF::Action(&quot;_root.attachMovie('mc','mc1',11);&quot;);</pre>
</dd>
</li>
<dt><strong><a name="writeexports" class="item">$m-&gt;<code>writeExports()</code></a></strong>

<dd>
<p>Export prepared names to Action script.</p>
</dd>
</li>
<dt><strong><a name="remove" class="item"><code>remove($displayItem)</code></a></strong>

<dd>
<p>Removes the given SWF::DisplayItem instance from the current and following frames of the main timeline.</p>
</dd>
<dd>
<pre>
        $m-&gt;remove($shape_i);</pre>
</dd>
</li>
<dt><strong><a name="nextframe" class="item"><code>nextFrame()</code></a></strong>

<dd>
<p>Finish a frame of the main timeline. New added objects will be added in the next frame.</p>
</dd>
<dd>
<pre>
        $m-&gt;nextFrame();</pre>
</dd>
</li>
<dt><strong><a name="setnumberofframes" class="item"><code>setNumberOfFrames($frames)</code>
=item <code>setFrames($frames)</code></a></strong>

<dd>
<p>Preset the number of frames of the main timeline. n not used frames before finishing the movie will filled with n <a href="#nextframe"><code>nextFrame()</code></a> statements.
If you inserted more <a href="#nextframe"><code>nextFrame()</code></a> commands than you set with <code>setFrames()</code> the <code>setFrames()</code> will be ignored.</p>
</dd>
<dd>
<pre>
        $m-&gt;setFrames(100);</pre>
</dd>
</li>
<dt><strong><a name="setbackground" class="item">$m-&gt;<code>setBackground($red,$green,$blue)</code></a></strong>

<dd>
<p>Set the background in red, green, blue values. Possible value are 0..255 or hexvalues 0x0..0xff.</p>
</dd>
<dd>
<pre>
        $m-setBackground(0xff,0x99,0x00); # orange bg
        $m-setBackground(0,200,255)       # green bg</pre>
</dd>
<dd>
<p>A transparency level isn't available I asume. (In Flash MX/F6?). A transparent background can be set in the HTML-code for Internet Explorer. Please 
inform the Authors if that is available for nonIE-browsers.</p>
</dd>
</li>
<dt><strong><a name="namedanchor" class="item">$m-&gt;<code>namedAnchor($label)</code></a></strong>

<dd>
<p>This function adds a named anchor to the movie.</p>
</dd>
</li>
<dt><strong><a name="setdimension" class="item">$m-&gt;setDimension(x,y)</a></strong>

<dd>
<p>Set the dimension in pixel.</p>
</dd>
<dd>
<pre>
        #ToDo:
        #min: (0.0,0.0)   # ;-)
        #max: (?,?)
        #default: (0.0?,0.0?)
        #Behavior when values &lt;min: ming sets it to min
        #Behavior when values &gt;max: ming sets it to max</pre>
</dd>
<dd>
<pre>
        $m-&gt;setDimension(200,100);
        $m-&gt;setDimension(123.45,67.89);</pre>
</dd>
</li>
<dt><strong><a name="setrate" class="item">$m-&gt;setRate(int)</a></strong>

<dd>
<p>Set the playing speed in frames/second.</p>
</dd>
<dd>
<pre>
        #ToDo:
        #min: 0
        #max: ?
        #default: ?
        #Behavior when value &lt;min: ming sets it to min
        #Behavior when value &gt;max: ming sets it to max</pre>
</dd>
<dd>
<pre>
        $m-&gt;setRate(30);</pre>
</dd>
</li>
<dt><strong><a name="protect" class="item">$m-&gt;<code>protect()</code></a></strong>

<dd>
<p>A feature that prevents only flashnewbies from importing your movie into Macromedias Flash authoring tools. It cannot protect your content from being loaded by 
other flashmovies, deleting of the protection with a hexeditor or disassembling with tools.</p>
</dd>
</li>
<dt><strong><a name="setsoundstream" class="item">$m-&gt;setSoundStream($soundstream, [$skip])</a></strong>

<dd>
<p>Puts an SWF::SoundStream object as streaming sound into the main timeline.
The optional skip parameter describes the time in seconds to be skiped.</p>
</dd>
<dd>
<pre>
        $m-&gt;setSoundStream($soundstream);</pre>
</dd>
</li>
<dt><strong><a name="streammp3" class="item">$m-&gt;streamMp3($filename)</a></strong>

<dd>
<p>Simplifies the <a href="#setsoundstream"><code>setSoundStream()</code></a>. You only need the filename.</p>
</dd>
<dd>
<pre>
        $m-&gt;streamMp3(&quot;iloveyou.mp3&quot;);</pre>
</dd>
<dd>
<p>Hint: If you want to reuse this sound/mp3 later in this movie, create a reusable SWF::SoundStream object and then put it into <code>setSoundstream()</code>.</p>
</dd>
</li>
<dt><strong><a name="startsound" class="item">$soundinstance = $m-&gt;<code>startSound($sound)</code></a></strong>

<dd>
<p>Play a prepared SWF::Sound object into the main timeline. Returns an object of SWF::SoundInstance.</p>
</dd>
<dd>
<pre>
        $sound = new SWF::Sound(&quot;loveyoutoo.mp3&quot;, SWF_SOUND_MP3_COMPRESSED );  
        $si = $m-&gt;startSound($sound);</pre>
</dd>
</li>
<dt><strong><a name="stopsound" class="item">$m-&gt;<code>stopSound($sound)</code></a></strong>

<dd>
<p>Stop playing sound.</p>
</dd>
</li>
<dt><strong><a name="labelframe" class="item">$m-&gt;<code>labelFrame($string)</code></a></strong>

<dd>
<p>Gives the current frame a label that can be used by actionscript as anchor. Then you don't have to count your <a href="#nextframe"><code>nextFrame()</code></a> lines anymore. :-)</p>
</dd>
<dd>
<pre>
        $m-&gt;labelFrame(&quot;win&quot;);
        #ToDo:
        #max characters of a label??? 
        #What happen if we put there a big string?? 
        #Which characters are allowed??</pre>
</dd>
</li>
<dt><strong><a name="setscriptlimits" class="item">$m-&gt;setScriptLimits($maxRecursion, $timeout)</a></strong>

<dd>
<p>Set limits for resource usage, related to action script. Setting timeout will protect your computer from too long loops
and stack overflow. So endless scripts like &quot;while (1){};&quot; will be interrupted after timeout seconds.  The default 
recursion depth is 265, the default timeout is 15 seconds.</p>
</dd>
</li>
<dt><strong><a name="definescene" class="item">$m-&gt;defineScene($offset, $name)</a></strong>

<dd>
<p>Define scenes for the movies' main timeline using integer value for frame offset and name of the scene.</p>
</dd>
</li>
<dt><strong><a name="setnetworkaccess" class="item">$m-&gt;<code>setNetworkAccess($flag)</code></a></strong>

<dd>
<p>Sets network / fileaccess policy. If the flag is set to 0 a localy loaded 
movie will be unable to access the network but is allowed to access local files.
If the flag ist set to 1 a localy loaded movie will be unable to access local files
but is allowed to access the network. For SWF &gt;= 8: default is 0,</p>
</dd>
</li>
<dt><strong><a name="addmetadata" class="item">$m-&gt;<code>addMetadata($xml)</code></a></strong>

<dd>
<p>Adds Metadata to the movie: this function inserts a metadata-tag
into the movie. Only one metadata-tag can be set to a movie. 
Metadata is specified as an XML string.</p>
</dd>
</li>
<dt><strong><a name="assignsymbol" class="item">$m-&gt;assignSymbol($character, $name)</a></strong>

<dd>
<p>Assigns a symbolic name for a SWF::Character object.
Such classes are available for usage in other SWF files
and can be referenced from inside the current movie.
To assign a symbol to the root movie use NULL as character value.</p>
</dd>
</li>
<dt><strong><a name="settabindex" class="item">$m-&gt;setTabIndex($depth, $index)</a></strong>

<dd>
<p>Sets tab index for specified depth level.</p>
</dd>
</li>
<dt><strong><a name="addfont" class="item">$fontchar = $m-&gt;<code>addFont($font)</code></a></strong>

<dd>
<p>Adds a font to a movie. An object of SWF::FontCharacter class returned.</p>
</dd>
<dd>
<pre>
        $font = new SWF::Font('Arial.fdb');                                                                                                                                                                              
        $fch  = $m-&gt;addFont($font);</pre>
</dd>
</li>
<dt><strong><a name="importfont" class="item">$fontchar = $m-&gt;importFont($file, $name)</a></strong>

<dd>
<p>Imports a font from an other SWFFile. An object of SWF::FontCharacter class returned.</p>
</dd>
<dd>
<pre>
        $fch = $m-&gt;importFont('textField.swf', 'Arial337a');</pre>
</dd>
</li>
<dt><strong><a name="importcharacter" class="item">$m-&gt;importCharacter($url, $name)</a></strong>

<dd>
<p>Not yet documented (ToDo!)</p>
</dd>
</li>
<dt><strong><a name="replace" class="item">$m-&gt;replace($item, $block)</a></strong>

<dd>
<p>Not yet documented (ToDo!)</p>
</dd>
</li>
<dt><strong><a name="xs_output" class="item">$m-&gt;<code>xs_output([$compresslevel])</code></a></strong>

<dt><strong><a name="output" class="item">$m-&gt;<code>output([$compresslevel])</code></a></strong>

<dd>
<p>Writes the SWF::Movie to stdout. This is normally used for webservers/cgi-scripts. 
Don't forget to send the &quot;Content-Type:&quot;-lines before writing out the movie.</p>
</dd>
<dd>
<p>The parameter compresslevel is optional. compresslevel between 0 and 9. Higher values will be interpreted as 9. Values smaller 0
mean no compression. By default the SWF::Movie will be send without compression.</p>
</dd>
<dd>
<p>Notice: compression available since Flash MX(Flash 6). Ming does not check this for you if you write flash4 or flash5 movies.</p>
</dd>
<dd>
<p>Unlike <a href="#xs_output"><code>xs_output()</code></a> the <a href="#output"><code>output()</code></a> method prepared for using via webservers (but not limited to webservers).</p>
</dd>
</li>
<dt><strong><a name="save" class="item">$m-&gt;save($filename [, $compresslevel])</a></strong>

<dd>
<p>Save the SWF::Movie to a file.</p>
</dd>
<dd>
<p>The parameter compresslevel is optional. compresslevel between 0 and 9. Higher values will be interpreted as 9. Values smaller 0 
mean no compression. By default the SWF::Movie will be saved without compression.</p>
</dd>
<dd>
<p>Notice: compression available since Flash MX(Flash 6). Ming does not check this for you if you write flash4 or flash5 movies.</p>
</dd>
</li>
</dl>
<p>
</p>
<hr />
<h1><a name="example">EXAMPLE</a></h1>
<p>3 examples: a regular minimal SWF::Movie, one with all methods and a more interesting.</p>
<dl>
<dt><strong><a name="minimal_empty_example" class="item">minimal empty example</a></strong>

<dd>
<pre>
        #!/usr/bin/perl -w
        use SWF::Movie;</pre>
</dd>
<dd>
<pre>
        $m = new SWF::Movie();
        $m-&gt;nextFrame();
        $m-&gt;save(&quot;emptyminimal.swf&quot;);</pre>
</dd>
<dt><strong><a name="full_empty_examples" class="item">full empty examples</a></strong>

<dd>
<pre>
        #!/usr/bin/perl -w
        use SWF::Movie;</pre>
</dd>
<dd>
<pre>
        $m = new SWF::Movie();
        $m-&gt;setVersion(4);
        $m-&gt;setBackground(0xff,0xcc,0x0);
        $m-&gt;setDimension(200,100);
        $m-&gt;protect();
        $m-&gt;setRate(30);
        $m-&gt;setFrames(10); # ming fills it automatic with frames</pre>
</dd>
<dd>
<pre>
        $m-&gt;nextFrame()
        $m-&gt;save(&quot;empty.swf&quot;);</pre>
</dd>
<dt><strong><a name="streaming_example" class="item">streaming example</a></strong>

<dd>
<pre>
        #!/usr/bin/perl -w
        use SWF(&quot;Shape&quot;);
        SWF::setVersion(6);</pre>
</dd>
<dd>
<pre>
        $m = new SWF::Movie();
        $m-&gt;setBackground(0xff,0xcc,0x0);
        $m-&gt;setDimension(200,100);
        $m-&gt;setFrames(10);
        $m-&gt;streamMp3(&quot;forever.mp3&quot;);</pre>
</dd>
<dd>
<pre>
        $s= new SWF::Shape();
        $s-&gt;setLine(40,0xff,0xff,0);
        $s-&gt;setRightFill(0xff,0,0); 
        $s-&gt;drawLine(50,0);
        $s-&gt;drawLine(0,20);
        $s-&gt;drawLineTo(0,0);</pre>
</dd>
<dd>
<pre>
        $s_1= $m-&gt;add($s);
        $s_2= $m-&gt;add($s);
        $s_1-&gt;move(50,40);
        $s_2-&gt;move(10,40);
        for($i=1;$i&lt;5;$i++) {
                $m-&gt;nextFrame();
                $s_2-&gt;move(0,10);
        }
        $m-&gt;nextFrame();
        print &quot;Content-type: application/x-shockwave-flash\n\n&quot;;
        $m-&gt;output(9); # with compression level 9 (since flash6)</pre>
</dd>
</dl>
<p>
</p>
<hr />
<h1><a name="author">AUTHOR</a></h1>
<p>Soheil Seyfaie (soheil at users.sourceforge.net), Albrecht Kleine and
developers of ming.sourceforge.net</p>
<p>
</p>
<hr />
<h1><a name="see_also">SEE ALSO</a></h1>
<p>SWF, SWF::Action, SWF::Bitmap, SWF::Button, SWF::Constants, SWF::DisplayItem, SWF::Fill, 
SWF::Font, SWF::FontCharacter, SWF::Gradient, SWF::Morph, SWF::MovieClip, SWF::Shape, 
SWF::PrebuiltClip, SWF::Sound, SWF::SoundStream, SWF::TextField, SWF::Text, SWF::Filter, SWF::Character</p>

</body>

</html>
